package com.jack.charging.order.rabbitmq;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * @author Jack
 * @date 2025/2/14 10:47
 * @see
 * @since
 */
@Component
public class RabbitMQProducer {
    @Autowired
    private RabbitTemplate rabbitTemplate;

    @Value("${rabbitmq.exchange.name}")
    private String exchangeName;

    @Value("${rabbitmq.routing.key}")
    private String routingKey;
    public void sendMessage(String message) {
        // 发送消息到RabbitMQ
            rabbitTemplate.convertAndSend(exchangeName, routingKey, message);
            System.out.println("发送消息：" + message);
    }
}
